home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WWTCLKit / WWTextFieldCellIBInspector.m < prev    next >
Encoding:
Text File  |  1995-03-22  |  2.1 KB  |  80 lines

  1.  
  2. #import "WWTextFieldCell.h"
  3. #import "WWTextFieldCellIBInspector.h"
  4.  
  5. @implementation WWTextFieldCellIBInspector
  6.  
  7. - init 
  8. {
  9.    char buf[MAXPATHLEN + 1];
  10.    id bundle = [NXBundle bundleForClass:[WWTextFieldCell class]];
  11.     
  12.  
  13.    [super init];
  14.  
  15.    controlStringSize = 256;
  16.    controlString = (char *)NXZoneCalloc([self zone], controlStringSize, sizeof(char));
  17.  
  18.    tclExpressionSize = 256;
  19.    tclExpression = (char *)NXZoneCalloc([self zone], tclExpressionSize, sizeof(char));
  20.  
  21.    [bundle getPath:buf forResource:[[self class] name] ofType:"nib"];
  22.    [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
  23.  
  24.    // since the textView was "hidden" inside the ScrollView, we couldn't do this in IB, so...
  25.    [theControlStringText setDelegate:self];
  26.  
  27.    [self revert:self];
  28.  
  29.    return self;
  30. }
  31. //
  32. - free
  33. {
  34.   if (controlString) { NXZoneFree([self zone], controlString); }
  35.   if (tclExpression) { NXZoneFree([self zone], tclExpression); }
  36.   return [super free];
  37. }
  38. //
  39. - revert:sender 
  40. {
  41.   [theControlStringText setText:[object controlString]];
  42.   [theTclExpressionText setText:[object tclExpression]];
  43.   [theTclVar setStringValue:[object tclVar]];
  44.   return [super revert:sender];
  45. }
  46. //
  47. - ok:sender
  48. {
  49.   int   cnt;
  50.  
  51.   cnt = [theControlStringText textLength];
  52.   while (cnt >= controlStringSize)
  53.   {  controlStringSize *= 2;
  54.      controlString = (char *)NXZoneRealloc([self zone], controlString, controlStringSize);
  55.   }
  56.   *controlString = '\0';
  57.   [theControlStringText getSubstring:controlString start:0 length:(cnt + 1)];
  58.   [object setControlString:controlString];
  59.  
  60.   cnt = [theTclExpressionText textLength];
  61.   while (cnt >= tclExpressionSize)
  62.   {  tclExpressionSize *= 2;
  63.      tclExpression = (char *)NXZoneRealloc([self zone], tclExpression, tclExpressionSize);
  64.   }
  65.   *tclExpression = '\0';
  66.   [theTclExpressionText getSubstring:tclExpression start:0 length:(cnt + 1)];
  67.   [object setTclExpression:tclExpression];
  68.  
  69.   [object setTclVar:[theTclVar stringValue]];
  70.  
  71.   return [super ok:sender]; 
  72. }
  73. //
  74. - (BOOL)wantsTextFields    { return YES; }
  75.  
  76. // text delegate methods
  77. - textDidChange:sender {  return [self touch:sender]; }
  78.  
  79. @end
  80.